package com.ssy.lingxi.search.entity;

import com.ssy.lingxi.search.api.model.request.OftenCustomerAttributeRequest;
import com.ssy.lingxi.search.handler.converter.JpaJsonToListConverter;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.io.Serializable;
import java.util.List;

/**
 * 商城的常用筛选
 * @author jw.chen
 * @version 2.0.0
 * @date 2020/9/2
 */
@Getter
@Setter
@Entity
@Table(schema = "public", name = "product_shop_often_select", indexes = {@Index(name = "product_shop_often_select_user_id_idx", columnList = "userId"),
        @Index(name = "product_shop_often_select_name_idx", columnList = "name")})
public class OftenSelect implements Serializable {
    private static final long serialVersionUID = 2863184182456030626L;
    /**
     * 主键id
     */
    @Id
    @GeneratedValue(strategy= GenerationType.SEQUENCE, generator="shop_often_select_seq")
    @SequenceGenerator(sequenceName="product_shop_often_select_seq", name="shop_often_select_seq",allocationSize = 1)
    private Long id;

    /**
     * 名称
     */
    @Column(columnDefinition = "varchar(20)", nullable = false)
    private String name;

    /**
     * 分类id
     */
    @Column(columnDefinition = "int8")
    private Long customerCategoryId;

    /**
     * 分类名称
     */
    @Column(columnDefinition = "varchar(20)")
    private String customerCategoryName;

    /**
     * 属性
     */
    @Convert(converter = JpaJsonToListConverter.class)
    @Column(columnDefinition="jsonb")
    private List<OftenCustomerAttributeRequest> customerAttributeList;

    /**
     * 品牌id
     */
    @Column(columnDefinition = "int8")
    private Long brandId;

    /**
     * 品牌名称
     */
    @Column(columnDefinition = "varchar(20)")
    private String brandName;

    /**
     * 最大值
     */
    @Column(columnDefinition = "decimal")
    private Double max;

    /**
     * 最小值
     */
    @Column(columnDefinition = "decimal")
    private Double min;

    /**
     * 省份行政编号
     */
    @Column(columnDefinition = "varchar(20)")
    private String provinceCode;

    /**
     * 省份名称
     */
    @Column(columnDefinition = "varchar(20)")
    private String provinceName;

    /**
     * 城市行政编号
     */
    @Column(columnDefinition = "varchar(20)")
    private String cityCode;

    /**
     * 城市名称
     */
    @Column(columnDefinition = "varchar(20)")
    private String cityName;

    /**
     * 产品定价：1-现货价格, 2-价格需要询价, 3-积分兑换商品
     */
    @Column(columnDefinition = "int")
    private Integer priceType;

    /**
     * 用户id
     */
    @Column(columnDefinition = "int8", nullable = false)
    private Long userId;

    /**
     * 用户名称
     */
    @Column(columnDefinition = "varchar(50)", nullable = false)
    private String userName;

    /**
     * 创建时间
     */
    @Column(columnDefinition = "int8", nullable = false)
    private Long createTime = System.currentTimeMillis();
}
